package com.stylefeng.guns.config.webSocket;

import com.stylefeng.guns.config.handler.WsHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import org.springframework.web.socket.config.annotation.*;


/**
 * Created by brunoli on 2018/5/14.
 */
@Configuration
@EnableWebSocket
public class WebSocketConfig  implements WebSocketConfigurer{



    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry)
    {
        System.out.println("==========================");
        registry.addHandler(myHandler(), "/websocket").setAllowedOrigins("*");
    }

    @Bean
    public WsHandler myHandler()
    {
        return new WsHandler();
    }

}
